package com.adams.action.view;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.adams.common.BaseAction;
import com.adams.custom.page.util.DataOperateMessageUtil;
import com.adams.encache.mechanism.CacheUtil;

public class ViewCacheClearAction extends BaseAction
{

	/**
	 * Description : <Detail Description for package> Author : 904370
	 */
	private static final long serialVersionUID = -366132137274881111L;

	@SuppressWarnings("unchecked")
	public String invoke() throws Exception
	{
		String message = request
				.getParameter(DataOperateMessageUtil.MESSAGE_PARAM);
		JSONArray list = JSONArray.fromObject(message);
		int len = list.size();
		for (int i = 0; i < len; i++)
		{
			JSONObject data = list.getJSONObject(i);
			Map messageMap = (Map) JSONObject.toBean(data, HashMap.class);
			// 表名
			String tablecode = (String) messageMap
					.get(DataOperateMessageUtil.TABLE_NAME);
			// 操作类型
			// String operate =
			// (String)messageMap.get(DataOperateMessageUtil.ACTION_TYPE);
			CacheUtil.clearCacheByTablecode(tablecode);
		}
		return null;
	}
}
